import types from './types'
import comTypes from '../com/types'
import {request, METHODS} from '@/utils'

const actions = {
  userLogin: (context, data) => {
    context.commit(comTypes.SET_LOADING, true, {root: true})
    request('/test/getInteger', data).then(res => {
      context.commit(types.USER_LOGIN, res)
      context.commit(comTypes.SET_LOADING, false, {root: true})
    })
  },
  createTodo: (context, data) => {
    context.commit(comTypes.SET_LOADING, true, {root: true})
    return request('/api/todo/v1/todo', data, METHODS.POST).then(res => {
      context.commit(types.USER_LOGIN, res)
      context.commit(comTypes.SET_LOADING, false, {root: true})
    })
  }
}
export default actions
